<!DOCTYPE html>
<html xmlns:layout="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
	layout:decorate="~{common/layout}">

<head>
	<meta charset="UTF-8">
	<title>登录-血糖记录管理系统</title>
	<style scoped lang="less">

	</style>
</head>

<body>
	<div layout:fragment="fragment_body">
		<!--<van-row>
			<van-nav-bar title="用户登录">
				<template #left></template>
				<template #right></template>
			</van-nav-bar>
		</van-row>-->
		<van-row style="margin-top:30%">
			<h2 class="van-doc-demo-block__title" style="text-align: center;">用户注册</h2>
			<van-form @submit="onSubmit">
				<van-field v-model="username" name="username" label="用户名" placeholder="用户名"
					:rules="[{ required: true, message: '请填写用户名' }]" ></van-field>
				<van-field v-model="usernick" name="usernick" label="昵称" placeholder="昵称"
					:rules="[{ required: true, message: '请填写昵称' }]" ></van-field>
				<van-field v-model="password" type="password" name="password" label="密码" placeholder="密码"
					:rules="[{ required: true, message: '请填写密码' }]" ></van-field>
				<div style="margin: 16px;">
					<van-button round block type="info" native-type="submit">注册</van-button>
				</div>
				<div style="margin: 16px;">
					<div style="text-align: right;">有账号？请点击<a href="/user/login">登录</a></div>
				</div>
			</van-form>
		</van-row>
	</div>
</body>
<script type="text/javascript" layout:fragment="fragment_script">
	let vueData = {
		activeMenu: 'my',
		username: '',
		usernick: '',
		password: '',

	}
	let vueMethods = {
		onSubmit(values) {
			let that = this
			let pp = {
				user: that.username,
				nick: that.usernick,
				password: that.password
			}
			postRequst('/user/register', pp, true).then(function (resp) {
				if(resp.status === 0){
					that.$toast.success(resp.msg);
					setTimeout(function(){
						window.location.href='/user/login'
					},1000)
				}else{
					that.$toast(resp.msg);
				}
			})
		},
	}
	function vueCreated() {
		let that = this
	}
</script>

</html>